package com.multimedia.scala.euler

object Asd39 {
	def main(args : Array[String]) : Unit = {

		def getCombinations(sum: Int): Int = {
			def isTriangle(a: Int, b: Int, c: Int) = a*a+b*b == c*c

		    var z = sum/3   //z iz greater then sum/3 
		    val max = sum/2 //z iz less then sum/2

		    var rez = 0
		    while (z < max) {
		        var y = 2
		        while (y < z) {
		            val x = sum - z - y
		            if (x < y && isTriangle(x, y, z)) {
		                println(x, y, z)
		                rez += 1
		            }
		            y += 1
		        }
		        z += 1
		    }
			return rez
		}

		println((100 to 1000).map(x=>getCombinations(x)->x).max)
	}
}
